// A-B数对
#include <iostream>
#include <algorithm>
#include <algorithm>
using namespace std;
const int N = 2e5 + 10;
typedef long long LL;
LL a[N];
int n, c;

int binary_search(LL t)
{
    int l = 1, r = n;
    while(l < r)
    {
        LL mid = (l + r) / 2;
        if(a[mid] >= t) r = mid;
        else l = mid + 1;
    }

    int tmp = l;
    
    l = 1, r = n;
    while(l < r)
    {
        LL mid = (l + r + 1) / 2;
        if(a[mid] <= t) l = mid;
        else r = mid - 1;
    }
    // 考虑极端情况，t大于所有数
    if(tmp > l) return 0;
    return l - tmp + 1;
}

int main()
{
    cin >> n >> c;
    for(int i = 1;i <= n;i++) cin >> a[i];

    sort(a + 1, a + n + 1);
    LL ret = 0;
    a[0] = -1;
    for(int i = 1;i <= n;i++)
    {
        
        LL t = a[i] + c;
        // ret += upper_bound(a + 1, a + n + 1, t) - lower_bound(a + 1, a + n + 1, t);
        if (a[n] < t) continue;
        ret += binary_search(t);
        
    }

    cout << ret << endl;
}